package io.github.yuegod.clean.acl.model;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author quziwei
 * @date 2021/8/5 8:52
 **/
@Data
@Accessors(chain = true)
public class Result {

    private Boolean success;

    private JSONObject data;

    private String msg;

    public static Result ok(JSONObject data) {
        return new Result()
                .setSuccess(true)
                .setData(data)
                .setMsg(null);
    }

    public static Result ok() {
        return ok(null);
    }

    public static Result fail(String msg) {
        return new Result()
                .setSuccess(false)
                .setData(null)
                .setMsg(msg);
    }

    public static Result fail() {
        return fail(null);
    }
}
